import service from '@/utils/request'
import { prefix } from '../common'
import qs from 'qs'
export const useRoleMenuApi = () => {
	return service.post(prefix + '/sys/menu/getMenuButton')
}

export const useRoleApi = (id: number) => {
	return service.get(prefix + '/sys/role/menus?id=' + id)
}

export const useRoleListApi = (data: any) => {
	return service.get(prefix + '/sys/role/page', {
		params: {
			page: data.page ? data.page : 1,
			limit: data.limit ? data.limit : 10
		},
		paramsSerializer: params => {
			return qs.stringify(params)
		}
	})
}

export const useRoleNameListApi = (idList: number[]) => {
	return service.post('/sys/role/nameList', idList)
}

export const useRoleSubmitApi = (dataForm: any) => {
	return service.post(prefix + '/sys/role', dataForm)
}

export const useRoleDataScopeSubmitApi = (dataForm: any) => {
	return service.put(prefix + '/sys/role/data-scope', dataForm)
}

export const useRoleUserSubmitApi = (roleId: number, dataForm: any) => {
	return service.post(prefix + '/sys/role/user/' + roleId, dataForm)
}
